﻿#pragma once
#include "json_trans.h"
#include "systemcfg_data.h"

/******************通信配置*****************/
/*机械手配置*/
json_struct(RobotJ,
	mapping(QString, id);
mapping(QString, brand);
mapping(QString, ip);
mapping(int, statePort);
mapping(int, cmdPort);
mapping(PositionJ, origin);
prop(&id, &brand, &ip, &statePort, &cmdPort, &origin);
)

RobotSetting TransFromRobotJ(const RobotJ& in);
/*wcs 通信配置*/
json_struct(WCSCfgJ,
	mapping(int, type);
mapping(QString, robIP);
mapping(int, robPort);
mapping(QString, wcsIP);
mapping(int, wcsPort);
prop(&type, &robIP, &robPort, &wcsIP, &wcsPort);
);


WCSSetting TransFromWCScfgJ(const WCSCfgJ& in);

/*相机配置*/
json_struct(CameraCfg,
	mapping(QString, id);
mapping(QString, type);
mapping(QString, ip);
mapping(QString, bd);	// 标定文件
mapping(QString, alg);	// 算法插件名称
prop(&id, &type, &ip, &bd, &alg);
);

/*视觉配置*/
json_struct(VisualJ,
	mapping(QList<CameraCfg>, cameras);
mapping(QString, picpath);
mapping(QString, visPath);
prop(&cameras, &picpath, &visPath);
);
json_struct(JigCfg,
	mapping(int, id);
mapping(int, type);
mapping(SizeJ, size);
mapping(PositionJ, rob);
prop(&id, &type, &size, &rob);
)
JigSetting TransFormJigCfg(const JigCfg& in);
/***********************************点位配置**************************************/



json_struct(UnstackAlgCfg,
	mapping(QString, calibration);
mapping(JigCfg, jig);
mapping(int, dirX);
mapping(int, dirY);
mapping(SizeJ, maxSku);
mapping(SizeJ, minSku);
mapping(int, sizeCheck);	// 1：启用 0:不启用
mapping(int, maxnum);
prop(&calibration, &jig, &dirX, &dirY, &maxSku, &minSku, &sizeCheck, &maxnum);
);
UnstackAlgSetting TransFromUnstackAlgCfg(const UnstackAlgCfg& in);

/*码垛托盘配置*/
json_struct(StackPlateCfg,
	mapping(QString, id);
mapping(int, di);
mapping(int, dirOdd);
mapping(int, dirEven);
mapping(PositionJ, base);
mapping(QString, alg);
mapping(SizeJ, maxsize);
prop(&id, &di, &dirOdd, &dirEven, &base, &alg, &maxsize);
);

StackPlateSetting TransFormStackPlateCfg(const StackPlateCfg& in);

/*拆垛托盘配置*/
json_struct(UnstackPlateCfg,
	mapping(QString, id);
	mapping(QString, camera);
	mapping(int, max);
	mapping(int, dir);
prop(&id, &camera, &max, &dir);
)

UnstackPlateSetting TransFormUnstackPlateCfg(const UnstackPlateCfg& in);

/*输送线点位配置*/
json_struct(BoxlineCfg,
	mapping(QString, id);
mapping(int, type);
mapping(QString, di);
mapping(QString, dival);
mapping(int, posid);
mapping(int, dir);
mapping(PositionJ, base);
mapping(QString, alg);
prop(&id, &posid, &base, &alg, &dir);
);
BoxlineSetting TransFromBoxlineCfg(const BoxlineCfg& in);

/*托盘垛配置*/
json_struct(PlateStackCfg,
	mapping(int, valied);
mapping(QString, id);
mapping(QString, rob);
mapping(int, ph);
mapping(int, minDi);
mapping(int, maxDi);
mapping(PositionJ, base);
prop(&valied, &id, &rob, &ph, &minDi, &maxDi, &base);
);



/************************安全配置*******************************/
json_struct(Input,
	mapping(QString, name);
mapping(int, di);
mapping(int, val);
prop(&name, &di, &val);
);

InputWare TransFromInput(const Input& in);

json_struct(Output,
	mapping(QString, name);
mapping(int, doindex);
mapping(int, val);
prop(&name, &doindex, &val);
);

OutputWare TransFromOutput(const Output& in);

json_struct(SafeDoorJ,
	mapping(int, enable);	// 1:启用
mapping(int, stop);
mapping(int, reset);
mapping(int, start);
mapping(int, enter);
prop(&enable, &stop, &reset, &start, &enter);
);

SafedoorSetting TransFromSafeDoorJ(const SafeDoorJ& in);

json_struct(GratingJ,
	mapping(QString, id);
mapping(int, enable);	// 1:启用
mapping(int, trig);
mapping(int, fault);
prop(&id, &trig, &fault, &enable);
);

GratingSetting TransFromGratingJ(const GratingJ& in);

json_struct(AlarmJ,
	mapping(int, enable);	// 1:启用
mapping(int, red);
mapping(int, green);
mapping(int, yellow);
prop(&red, &green, &yellow, &enable);
);

AlarmSetting TransFromAlarmJ(const AlarmJ& in);

json_struct(SafeLockJ,
	mapping(int, enable);
mapping(int, state);
mapping(int, set);
prop(&state, &set, &enable);
);

SafeLockSetting TransFromSafeLockJ(const SafeLockJ& in);

json_struct(SecuritySetting,
	mapping(SafeDoorJ, safedoor);
mapping(SafeLockJ, safelock);
mapping(AlarmJ, alarm);
mapping(QList<GratingJ>, grating);
prop(&safedoor, &safelock, &alarm, &grating);
);

/**********************业务线配置*****************************/
json_struct(RelativePointCfg,
	mapping(PositionJ, diff);
mapping(int, relateNum);
mapping(bool, fix_x);
mapping(bool, fix_y);
mapping(bool, fix_z);
mapping(bool, fix_a);
mapping(bool, fix_b);
mapping(bool, fix_c);
prop(&diff, &relateNum, &fix_x, &fix_y, &fix_z, &fix_a, &fix_b, &fix_c);
);

RelativePoint TransFormRelativePointCfg(const RelativePointCfg& in);

json_struct(LocationPointCfg,
	mapping(int, type);
mapping(QString, id);
prop(&type, &id);
);

LocationPoint TransFromLocationPointCfg(const LocationPointCfg& in);

json_struct(PointActionCfg,
	mapping(int, type);
mapping(QString, param);
prop(&type, &param);
);

PointAction TransFormPointActionCfg(const PointActionCfg& in);

json_struct(PathPointCfg,
	mapping(QString, name);
mapping(int, pointId);
mapping(int, pointType);
mapping(int, stop);
mapping(int, acc);
mapping(int, vel);
mapping(int, zone);
mapping(int, mathType);
mapping(PositionJ, fix);
mapping(RelativePointCfg, relate);
mapping(LocationPointCfg, location);
mapping(PointActionCfg, action);
prop(&name, &pointId, &pointType, &stop, &acc, &vel, &zone, &mathType, &fix, &relate, &location, &action);
);

PathPointSetting TransFromPathPointCfg(const PathPointCfg& in);

json_struct(PathCfg,
	mapping(int, id);
mapping(QString, name);
mapping(QList<PathPointCfg>, points);
prop(&id, &name, &points);
);

PathSetting TransFromPathCfg(const PathCfg& in);

json_struct(PipelineCfg,
	mapping(QString, id);
mapping(QString, rob);
mapping(int, type);
mapping(QString, start);
mapping(QString, end);
mapping(QList<PathCfg>, paths);
prop(&id, &rob, &type, &start, &end, &paths);
)

PipelineSetting TransFormPipelineCfg(const PipelineCfg& in);


json_struct(SystemSetting,
	mapping(QString, project);
mapping(RobotJ, robot);
mapping(JigCfg, jig);
mapping(WCSCfgJ, wcs);
mapping(VisualJ, camera);
mapping(PlateStackCfg, plateStack);
mapping(QList<BoxlineCfg>, boxline);
mapping(QList<StackPlateCfg>, stackplate);
mapping(QList<UnstackPlateCfg>, unstackplate);
mapping(SecuritySetting, safeHW);
mapping(QList<PipelineCfg>, pipeline);
mapping(QList<PathCfg>, path);
prop(&project, &robot, &jig, &wcs, &camera, &boxline, &stackplate, &unstackplate, &plateStack, &safeHW, &pipeline, &path);
)
